﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.APP.Application.Command.Photo;
using Traceability.Domain;
using Traceability.ErrorCode;

namespace Traceability.APP.Controllers
{
    /// <summary>
    /// Api 控制器-图片上传
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PhotoController : ControllerBase
    {
        private readonly IMediator mediator;

        public PhotoController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 图片上传的新增
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<APIResult<int>> PhotoAdd(AddPhotoCommand command)
        { 
            return mediator.Send(command);
        }

        /// <summary>
        /// 图片信息的显示
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<Photo_Model>>> PhotoShow([FromQuery] ShowPhotoCommand command)
        {
            return mediator.Send(command);
        }


        /// <summary>
        /// 图片信息的修改
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<APIResult<int>> UpdatePhoto(UpdatePhotoCommand command)
        {
            return mediator.Send(command);    
        }

    }
}
